package com.example.medicine.Mapper.yian;


import com.example.medicine.Bean.yian.yian_chufang;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface yian_chufangMapper {
    @Select("select * from [yian_chufang]")
    public List<yian_chufang> getAll();
    @Select("select * from [yian_chufang] where yianid=#{yianid}")
    public List<yian_chufang> getByYianId(long yianid);

    @Insert("insert into [yian_chufang](zhongyaoming,yaoliang,daiding,paozhi,chandi,beizhu,sort) values(#z{hongyaoming},#{yaoliang},#{daiding},#{paozhi},#{chandi},#{beizhu},#{sort})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    public void insertOne(yian_chufang yian_chufang);
    @Insert("<script>" +
            "INSERT INTO [yian_chufang] (yianid,zhongyaoming, yaoliang, daiding, paozhi, chandi, beizhu, sort) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.yianid},#{item.zhongyaoming}, #{item.yaoliang}, #{item.daiding}, #{item.paozhi}, #{item.chandi}, #{item.beizhu}, #{item.sort})" +
            "</foreach>" +
            "</script>")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void insertBatch(List<yian_chufang> list);

    @Delete("delete from [yian_chufang] where yianid=#{yianid}")
    public void deleteByYianId(long yianid);
}
